<?php
class Model_Category_Mapper extends App_Model_Mapper
{
	protected $_map = array (
	   'id'     => 'id',
	   'parent_id' => 'parent', 
	   'name'   => 'name'
	   );
	   protected $_entityClass = 'Model_Category';

	   protected function _setTable()
	   {
	   	return new Model_DbTable_Category();
	   }

	   public function getAll()
	   {
	   	   return $this->getArray($this->_table->fetchAll());
	   }
	   
	   public function getByGender($gender)
	   {
	        $db = $this->_table->getAdapter();
            $select = $db->select()->from(array('c'=>'category'))->join(array('p'=>'product'),'p.category_id = c.id',array() )
                ->where("lower(p.gender) like lower('%$gender%')")->group('c.id');  
            $res = $db->fetchAll($select);
            return $this->getArray($res);
	   }
	   

}